list1 = []
list2 = list ()
list3=[1,2,3,4,5,'aa','bb']
for i in list3:
   print( i,end='')



   print(list3[:4])
   print(list3[1:4])
   print(list3[1:])
   print(list3[:-1])
   print(list3[::2])




  #追加元素

   list3.append(6)
   list3.extend([7,8,9,])
   list3.insert(0,0)
   print(list3)
   for i in list3:
      print(i,end='')


   #列表排序
list4  = [78,89,90,44,55]
list4.sort()
print(list4)
#list4.reverse()
list4.sort(reverse=True)
print(list4)





#创建新列表
list_new = sorted(list4)
print(list_new)
list_new = sorted(list4,reverse=True)



#删除元素
del list4[0]
print(list4)
#del list4
#print(list4[0])#错误找不到
list4.remove(44)
print(list4)
#删除末尾元素
list4.pop()
print(list4)
#清空列表
list4.clear()
print(list4)

list5 = [11,22,3,4,15,36,7,18,9]
list5_new = [i for i in list5 if i>10]
print(list5_new)

#传统for循环
list5_new2 =[]
for i in list5:
    if i>10:
        list5_new2.append(i)




#集合
set1 = {1,2,3,4,5,6,7,8,9,10}
print(set1)
set1.remove(1)
print(set1)
set1.discard(2)
print(set1)
set1.pop()
print(set1)


#字典
dict1 = {'name':'张三','age':18,'sex':'男'}
print(dict1)
print(dict1['name'])
print(dict1.get('gender','没有相关数据'))
print(dict1.keys())
list7 = list(dict1.keys())
print(list7)

print()
dict1['id'] = 1001
print(dict1)
dict1.pop('sex')
print(dict1)

item = dict1.popitem()
print(item)
print(type(item))
print(dict1)

list8 = [1,2,3]
list9 = [4,5,6]
print(list8+list9)

print(list8*3)
print(1 in list8)
print(4 in list8)

